/*****************************************
Online Appendix E
Replicating results controlling for demographics
*******************************************/

clear
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\Online Appendix E"
log using "appendix_oe_log.log"
use "comb_educ.dta"
set more off

/**********************************************
Figure 1
**********************************************/

/****Some Initial Cleaning*****/
label var treat_3 "Treatment Condition"
label var support01 "Policy Support"

label def edu 1 "HS or Less" 2 "Some College" 3 "BA" 4 "Post-BA"
label values educ edu


gen polissue = . 
	replace polissue = 1 if experiment == "Experiment 1"
	replace polissue = 2 if experiment == "Experiment 2"  & pol_exp == "Tax:Conservative"
	replace polissue = 3 if experiment == "Experiment 2" & pol_exp == "Tax:Liberal"
	replace polissue = 4 if experiment == "Experiment 3" & pol_exp == "Tax:Conservative"
	replace polissue = 5 if experiment == "Experiment 3"& pol_exp == "Tax:Liberal"
label var polissue "Experiment & Issue"
label def pol1 1 "Experiment 1" 2 "Exp 2: Conservative Change" ///
				3 "Exp 2: Liberal Change" 4 "Exp 3: Conservative Change" ///
				5 "Exp 3: Liberal Change"
label values polissue pol1

label var treat_policy "Policy Treatment"

/******Models******/
eststo clear
regress support01 i.treat_3 i.polissue i.educ
	estimates store m1
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)

regress support01 i.treat_3 i.educ if experiment == "Experiment 1"
	estimates store m2
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)
	
regress support01 i.treat_3 i.educ i.treat_policy if experiment == "Experiment 2"
	estimates store m3
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)
	
regress support01 i.treat_3 i.educ i.treat_policy if experiment == "Experiment 3"
	estimates store m4
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)

/*******Table******/
esttab m1 m2 m3 m4 using "table_oe1_table.rtf", replace ///
	onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("Pooled" "Exp. 1" "Exp. 2" "Exp. 3") ///
	title("{\b Table OE1:} Figure 1 Analyses with Education Controls") ///
	stats(N diff sig) ///
	addnotes("The baseline category for the cue treatment is the No Cue condition. The base category for experiment/policy in the Pooled model is Experiment 1. The base category for the policy treatment in Exp. 2 and 3 models is the Conservative Change condition")
	

/**********************************************
Figure 2
**********************************************/

encode experiment, gen(exp)

/*****Models******/
eststo clear
eststo: regress support01 i.treat_3##i.stereo i.exp i.educ
eststo: regress support01 i.treat_3##i.stereo i.educ if experiment == "Experiment 2"
eststo: regress support01 i.treat_3##i.stereo i.educ if experiment == "Experiment 3"

/*****Table******/
esttab using "table_oe2.rtf", replace ///
	onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("Pooled" "Exp 2." "Exp. 3") ///
	title("{\b Table OE2:} Figure 2 Analyses, Controlling for Education") ///
	addnotes("The baseline category for the cue treatment is the No Cue condition. The base category for policy stereotypicality is counter-stereotypical. The base for experiment is Experiment 2.")

/******Calculate marginal effect******/
*Both
drop _est_*

eststo clear
regress support01 i.treat_3##i.stereo i.exp i.educ
	margins, dydx(treat_3) by(stereo) post
	estimates store m1
	
regress support01 i.treat_3##i.stereo i.educ if experiment == "Experiment 2"
	margins, dydx(treat_3) by(stereo) post
	estimates store m2
	
regress support01 i.treat_3##i.stereo i.educ if experiment == "Experiment 3"
	margins, dydx(treat_3) by(stereo) post
	estimates store m3
	
esttab m1 m2 m3  using "table_oe2_margins.rtf", replace ///
	onecell label nobaselevels b(2) ci ///
	mtitles("Both Experiments" "Experiment 2" "Experiment 3") ///
	title("{\b Table OE3:} Marginal Effects From Table OE2")
	
/******differences******/	
	
regress support01 i.treat_3##i.stereo i.exp i.educ 
	margins, dydx(treat_3) by(stereo) post coeflegend
	*stereotypical
	lincom  _b[2.treat_3:2.stereo] -  _b[3.treat_3:2.stereo]	
	*counter-stereotypical
	lincom _b[2.treat_3:1bn.stereo] - _b[3.treat_3:1bn.stereo]

regress support01 i.treat_3##i.stereo  i.educ if experiment == "Experiment 2"
	margins, dydx(treat_3) by(stereo) post coeflegend
	*stereotypical
	lincom  _b[2.treat_3:2.stereo] -  _b[3.treat_3:2.stereo]	
	*counter-stereotypical
	lincom _b[2.treat_3:1bn.stereo] - _b[3.treat_3:1bn.stereo]


regress support01 i.treat_3##i.stereo  i.educ if experiment == "Experiment 3"
	margins, dydx(treat_3) by(stereo) post coeflegend
	*stereotypical
	lincom  _b[2.treat_3:2.stereo] -  _b[3.treat_3:2.stereo]	
	*counter-stereotypical
	lincom _b[2.treat_3:1bn.stereo] - _b[3.treat_3:1bn.stereo]

	
	
	
/**********************************************
Figure 3
**********************************************/

drop _est_*

/****Models*****/
eststo clear
regress support01 i.treat_5 i.stereo i.educ
	estimates store m1
	lincom _b[2.treat_5] - _b[3.treat_5]
	estadd scalar diff1 = r(estimate)
	estadd scalar sig1 = r(t)
	lincom _b[2.treat_5] - _b[4.treat_5]
	estadd scalar diff2 = r(estimate)
	estadd scalar sig2 = r(t)
	lincom _b[2.treat_5] - _b[5.treat_5]
	estadd scalar diff3 = r(estimate)
	estadd scalar sig3 = r(t)
	
regress support01 i.treat_5 i.stereo i.educ if pid == 1
	estimates store m2
	lincom _b[2.treat_5] - _b[3.treat_5]
	estadd scalar diff1 = r(estimate)
	estadd scalar sig1 = r(t)
	lincom _b[2.treat_5] - _b[4.treat_5]
	estadd scalar diff2 = r(estimate)
	estadd scalar sig2 = r(t)
	lincom _b[2.treat_5] - _b[5.treat_5]
	estadd scalar diff3 = r(estimate)
	estadd scalar sig3 = r(t)
	
regress support01 i.treat_5 i.stereo i.educ if pid == 2
	estimates store m3
	lincom _b[2.treat_5] - _b[3.treat_5]
	estadd scalar diff1 = r(estimate)
	estadd scalar sig1 = r(t)
	lincom _b[2.treat_5] - _b[4.treat_5]
	estadd scalar diff2 = r(estimate)
	estadd scalar sig2 = r(t)
	lincom _b[2.treat_5] - _b[5.treat_5]
	estadd scalar diff3 = r(estimate)
	estadd scalar sig3 = r(t)

/*****Table*****/

esttab m1 m2 m3 using "table_oe4.rtf",  replace ///
	onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("All Partisans" "Republicans" "Democrats") ///
	title("{\b Table OB4:} Figure 3 Analyses Controlling for Education")  ///
	stats(N diff1 sig1 diff2 sig2 diff3 sig3)
	
	
		
/**********************************************
Figure 4 (Argument Rating Differences)
**********************************************/
drop _est_*

eststo clear
regress argdiff i.treat_3 i.polissue i.educ
	estimates store m1
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)
	
regress argdiff i.treat_3 i.educ if experiment == "Experiment 1"
	estimates store m2
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)
	
regress argdiff i.treat_3 i.educ i.treat_policy if experiment == "Experiment 2"
	estimates store m3
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)
	
regress argdiff i.treat_3 i.educ i.treat_policy if experiment == "Experiment 3"
	estimates store m4
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)

/*******Table******/
esttab m1 m2 m3 m4 using "table_oe5_table.rtf", replace ///
	onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("Pooled" "Exp. 1" "Exp. 2" "Exp. 3") ///
	title("{\b Table OE5:} Figure 4 Analyses (Argument Ratings) with Education Controls") ///
	stats(N diff sig) ///
	addnotes("The baseline category for the cue treatment is the No Cue condition. The base category for experiment/policy in the Pooled model is Experiment 1. The base category for the policy treatment in Exp. 2 and 3 models is the Conservative Change condition")
	
/**********************************************
Figure 4 (Inferences and Proximity)
**********************************************/

summ inferences
gen inf01 = (inferences - r(min))/(r(max)-r(min))


drop _est_*
eststo clear

regress inf01 i.treat_3 i.stereo i.educ 
	estimates store m1
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)
	
regress prox01 i.treat_3 i.stereo i.educ 
	estimates store m2
	lincom _b[2.treat_3] - _b[3.treat_3]
	estadd scalar diff = r(estimate)
	estadd scalar sig = r(t)
	
esttab m1 m2 using "table_oe6_table.rtf", replace ///
	onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("Inferences" "Proximity") ///
	title("{\b Table OE6:} Figure 4 Analyses (Inferences and Proximity) with Education Controls") ///
	stats(N diff sig) ///
	addnotes("The baseline category for the cue treatment is the No Cue condition.")
	
	
log close
	